home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINPROGS
/
UPC12BS1.ZIP
/
UUCP
/
UUXQT.C
< prev
Wrap
C/C++ Source or Header
|
1993-10-03
|
51KB
|
1,482 lines
/*
Program: uuxqt.c 23 September 1991
Author: Mitch Mitchell
Email: mitch@harlie.lonestar.org
This is a re-write of the (much cleaner) UUXQT.C originally
distributed with UUPC/Extended. The modifications are
intended primarily to lay a foundation for support for the
more advanced features of UUX.
Usage: uuxqt -xDEBUG -sSYSTEM
*/
/*--------------------------------------------------------------------*/
/* Changes Copyright (c) 1989-1993 by Kendra Electronic */
/* Wonderworks. */
/* */
/* All rights reserved except those explicitly granted by */
/* the UUPC/extended license agreement. */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* RCS Information */
/*--------------------------------------------------------------------*/
/*
* $Id: uuxqt.c 1.18 1993/10/03 22:10:24 ahd Exp $
*
* Revision history:
* $Log: uuxqt.c $
* Revision 1.18 1993/10/03 22:10:24 ahd
* Use signed for length of parameters
*
* Revision 1.17 1993/10/03 20:43:08 ahd
* Normalize comments to C++ double slash
*
* Revision 1.16 1993/09/29 23:29:56 ahd
* Add xqtrootdir for UUXQT
*
* Revision 1.15 1993/09/20 04:48:25 ahd
* TCP/IP support from Dave Watt
* 't' protocol support
* OS/2 2.x support (BC++ 1.0 for OS/2)
*
* Revision 1.14 1993/08/03 03:35:58 ahd
* Correct path pointer to initialized variable
*
* Revision 1.13 1993/08/03 03:11:49 ahd
* Initialize buffer for shell() in non-Windows environment
*
* Revision 1.12 1993/07/31 16:27:49 ahd
* Changes in support of Robert Denny's Windows support
*
* Revision 1.11 1993/07/24 03:40:55 ahd
* Agressively trap carriage returns at ends of lines (from X.* files
* being edited by elves with DOS editors!)
*
* Revision 1.10 1993/07/20 21:45:37 ahd
* Don't delete file after -2 abort from UUXQT
*
* Revision 1.9 1993/06/26 16:01:48 ahd
* Normalize white space used to parse strings
*
* Revision 1.8 1993/06/13 14:06:00 ahd
* Correct off-by-one error in RMAIL arg parse loop which crashed UUXQT
* on long system names
*
* Revision 1.7 1993/04/11 00:35:46 ahd
* Global edits for year, TEXT, etc.
*
* Revision 1.6 1993/04/05 04:35:40 ahd
* Use timestamp/file size information returned by directory search
*
* Revision 1.5 1992/11/25 12:59:17 ahd
* Change NUL to /dev/nul to prevent ImportPath() mangling.
*
* Revision 1.4 1992/11/23 03:56:06 ahd
* Selected fixes for use of generlized uux commands
*
* Revision 1.3 1992/11/19 03:03:33 ahd
* drop rcsid
*/
/*--------------------------------------------------------------------*/
/* System include files */
/*--------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <time.h>
#include <fcntl.h>
#include <process.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#ifdef _Windows
#include <windows.h>
#endif
/*--------------------------------------------------------------------*/
/* UUPC/extended include files */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "arpadate.h"
#include "dater.h"
#include "expath.h"
#include "getopt.h"
#include "getseq.h"
#include "hlib.h"
#include "hostable.h"
#include "import.h"
#include "lock.h"
#include "logger.h"
#include "pushpop.h"
#include "readnext.h"
#include "security.h"
#include "timestmp.h"
#include "usertabl.h"
#include "execute.h"
#ifdef _Windows
#include "winutil.h"
#endif
currentfile();
/*--------------------------------------------------------------------*/
/* Execution flag defines */
/*--------------------------------------------------------------------*/
typedef enum {
X_OUTPUT, /* 'O' return output to "outnode" */
X_FAILED, /* 'Z' send status if command failed */
X_SUCCESS, /* 'n' send status if command succeeded */
X_INPUT, /* 'B' return command input on error */
X_USEEXEC, /* 'E' process command using exec(2) */
X_STATFIL, /* 'M' return status to file on remote */
S_CORRUPT,
S_EMPTY,
S_NOREAD,
S_NOWRITE,
S_STDIN,
E_NORMAL,
E_NOACC,
E_SIGNAL,
E_STATUS,
E_NOEXE,
E_FAILED,
UU_LAST
} UU_FLAGS;
/*--------------------------------------------------------------------*/
/* Global Variables */
/*--------------------------------------------------------------------*/
static char *spool_fmt = SPOOLFMT;
static char *dataf_fmt = DATAFFMT;
static char *send_cmd = "S %s %s %s -%s %s 0666 %s\n";
/*--------------------------------------------------------------------*/
/* Internal prototypes */
/*--------------------------------------------------------------------*/
static void usage( void );
static boolean copylocal(const char *from, const char *to);
static boolean do_uuxqt( const char *sysname );
static void process( const char *fname,
const char *remote,
const char *executeDirectory);
char **create_environment(const char *logname,
const char *requestor);
static void delete_environment( char **envp);
static boolean AppendData( const char *input, FILE* dataout);
static boolean do_copy( char *localfile,
const char *rmtsystem,
const char *remotefile,
const char *requestor,
const boolean success );
static void ReportResults(const int status,
const char *input,
char *output,
const char *command,
const char *job_id,
const time_t jtime,
const char *requestor,
const char *outnode,
const char *outname,
const boolean xflag[],
const char *statfil,
const char *machine,
const char *user);
static int shell(char *command,
const char *inname,
const char *outname,
const char *remotename,
boolean xflag[]);
static boolean MailStatus(char *tempfile,
char *address,
char *subject);
/*--------------------------------------------------------------------*/
/* m a i n */
/* */
/* Main program */
/*--------------------------------------------------------------------*/
void main( int argc, char **argv)
{
int c;
extern char *optarg;
extern int optind;
char *sysname = "all";
/*--------------------------------------------------------------------*/
/* Report our version number and date/time compiled */
/*--------------------------------------------------------------------*/
debuglevel = 1;
banner( argv );
#if defined(__CORE__)
copywrong = strdup(copyright);
checkref(copywrong);
#endif
/*------------------------------------------